home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / apidev / ndr3.exe / SHOWVER.C < prev    next >
C/C++ Source or Header  |  1993-11-23  |  15KB  |  421 lines

  1. /*
  2.    SHOWVER   is a very simple NVER replacement that demonstrates
  3.              the use of the VERIPX, VERODI, VERNETX, VERVLM and
  4.              VERLITE modules.
  5.  
  6.    Author:  Tim Farley
  7.    Copyright 1993, Tim Farley, All Rights Reserved
  8. */
  9.  
  10. #include <stdlib.h>
  11. #include <stdio.h>
  12.  
  13.  
  14. /*
  15.    VERODI definitions
  16. */
  17. extern int GetLSLVersion( int * maxBoards, int * maxStacks );
  18. typedef struct {
  19.    char           Signature[ 26 ];     /* always "HardwareDriverMLID" */
  20.    unsigned char  ConfigTableMajorVer;
  21.    unsigned char  ConfigTableMinorVer;
  22.    unsigned char  NodeAddress[ 6 ];
  23.    unsigned int   ModeFlags;
  24.    unsigned int   BoardNumber;
  25.    unsigned int   BoardInstance;
  26.    unsigned int   MaxPacketSize;
  27.    unsigned int   BestDataSize;
  28.    unsigned int   WorstDataSize;
  29.    char far *     CardLongName;
  30.    char far *     CardShortName;
  31.    char far *     FrameString;
  32.    char           Reserved0[ 2 ];
  33.    unsigned int   FrameID;
  34.    unsigned int   TransportTime;
  35.    void far *     RouteHandler;
  36.    unsigned int   LookAheadSize;
  37.    unsigned int   LineSpeed;
  38.    unsigned int   QueueDepth;
  39.    char           Reserved1[ 6 ];
  40.    unsigned char  MLIDMajorVer;
  41.    unsigned char  MLIDMinorVer;
  42.    unsigned int   Flags;
  43.    unsigned int   SendRetries;
  44.    void far *     Link;
  45.    unsigned int   SharingFlags;
  46.    unsigned int   Slot;
  47.    unsigned int   IOAddress1;
  48.    unsigned int   IORange1;
  49.    unsigned int   IOAddress2;
  50.    unsigned int   IORange2;
  51.    unsigned long  MemoryAddress1;
  52.    unsigned int   MemorySize1;
  53.    unsigned long  MemoryAddress2;
  54.    unsigned int   MemorySize2;
  55.    unsigned char  IntLine1;
  56.    unsigned char  IntLine2;
  57.    unsigned char  DMALine1;
  58.    unsigned char  DMALine2;
  59. } MLIDConfigTable;
  60. typedef MLIDConfigTable far * MLIDPtr;
  61. extern int GetMLIDConfig( int boardNumber, MLIDPtr * configPtr );
  62.  
  63. typedef struct {
  64.     unsigned char  ConfigTableMajorVer;
  65.     unsigned char  ConfigTableMinorVer;
  66.     char far *     ProtocolLongName;
  67.     char far *     ProtocolShortName;
  68.     unsigned char  ProtocolMajorVer;
  69.     unsigned char  ProtocolMinorVer;
  70.    char           ConfigTableReserved[ 16 ];
  71. } ProtocolConfigTable;
  72. typedef ProtocolConfigTable far * ProtocolPtr;
  73. extern int GetProtocolConfig( int protoNumber, ProtocolPtr * configPtr );
  74. /* return values */
  75. #define GMC_SUCCESS           (int)(0)
  76. #define GMC_NO_MORE_ITEMS     (int)(0x8003)  /* not found & none beyond */
  77. #define GMC_ITEM_NOT_PRESENT  (int)(0x8004)  /* not found, but might be more */
  78.  
  79. extern char * GetNetCfgPath( void );
  80.  
  81.  
  82. /*
  83.    VERIPX definitions
  84.  
  85.    Note that these functions return version numbers "packed"
  86.    into a single int.  This allows easy version comparisons
  87.    like "GetIPXVersion() > 0x030A" (to test if IPX 3.10+
  88.    is present).  Each byte of the int should be interpreted
  89.    as a DECIMAL value.
  90. */
  91. extern int GetIPXVersion( void );
  92. extern int GetSPXVersion( void );
  93.  
  94.  
  95. /*
  96.    VERNETX definitions
  97.  
  98.    This is just a variation on the standard NetWare API call
  99.    of the same name.
  100. */
  101. extern int GetNetWareShellVersion( int * revLevel, int * shellType );
  102.  
  103.  
  104. /*
  105.    VERVLM definitions
  106. */
  107. extern int GetVLMVersion( int whichVLM );
  108. #define VLM_EXE      0x0001    /* VLM Manager                  */
  109. #define VLM_CONN     0x0010    /* Connection Table Manager     */
  110. #define VLM_TRAN     0x0020    /* Transport Multiplexor        */
  111. #define VLM_IPXNCP   0x0021    /* NCP over IPX                 */
  112. #define VLM_NWP      0x0030    /* NetWare Protocol             */
  113. #define VLM_BIND     0x0031    /* Bindery Services             */
  114. #define VLM_NDS      0x0032    /* Directory Services           */
  115. #define VLM_PNW      0x0033    /* Personal NetWare             */
  116. #define VLM_RSA      0x0034    /* RSA Security                 */
  117. #define VLM_REDIR    0x0040    /* DOS Redirector               */
  118. #define VLM_FIO      0x0041    /* File I/O                     */
  119. #define VLM_PRINT    0x0042    /* Printing Services            */
  120. #define VLM_GENERAL  0x0043    /* General NetWare API's        */
  121. #define VLM_NETX     0x0050    /* NETX Compatibility           */
  122. #define VLM_AUTO     0x0060    /* Auto re-connection           */
  123. #define VLM_SECURITY 0x0061    /* Security Services            */
  124. #define VLM_NMR      0x0100    /* NetWare Management Responder */
  125.  
  126.  
  127. /*
  128.    VERLITE definitions
  129. */
  130. extern int GetLiteClientVersion( void );
  131. extern int GetLiteServerVersion( void );
  132.  
  133.  
  134. /*
  135.    Macros for taking apart version numbers
  136. */
  137. #define HIBYTE(n) (((int)n >> 8) & 0xFF )
  138. #define LOBYTE(n) ( (int)n       & 0xFF )
  139.  
  140. /* function defined later in this module */
  141. void CopyFarStringToLocal( char * local, size_t localSize,
  142.    char far * remote );
  143.  
  144. /*
  145.    SHOWVER MAIN PROGRAM
  146. */
  147. int main( int argc, char ** argv )
  148. {
  149.    int LSLver, maxLSLboards, maxLSLstacks;
  150.    int board, protocol, returnCode;
  151.    char buff[ 75 ];
  152.    MLIDPtr mlidConfig;
  153.    ProtocolPtr protocolConfig;
  154.    int IPXver, SPXver;
  155.    int NETXver, NETXtype, NETXrev, VLMver, VLMModuleVer;
  156.    int NWLClient, NWLServer;
  157.    int vlmID, vlmCount = 0;
  158.  
  159.    printf( "SHOWVER -- Displays versions of loaded NetWare components\n"
  160.            "Copyright 1993, Tim Farley, All Rights Reserved\n\n" );
  161.  
  162.    /*
  163.       Use VERODI to get ODI driver information
  164.    */
  165.    LSLver = GetLSLVersion( &maxLSLboards, &maxLSLstacks );
  166.    if  ( 0 == LSLver )
  167.       printf( "ODI is not loaded\n" );
  168.    else {
  169.       printf( "LSL:      v%d.%02d", HIBYTE( LSLver ), LOBYTE( LSLver ) );
  170.       /*
  171.          Early versions of LSL don't support the max numbers,
  172.          so only display them if they are reasonable.
  173.       */
  174.       if ( 0 == maxLSLboards )
  175.          maxLSLboards = 8;    /* so our for loop later will work */
  176.       else
  177.          printf( ",  Max boards: %d", maxLSLboards );
  178.  
  179.       if ( 0 == maxLSLstacks )
  180.          maxLSLstacks = 8;    /* so our for loop later will work */
  181.       else
  182.          printf( ",  Max stacks: %d", maxLSLstacks );
  183.       printf( "\n" );
  184.  
  185.       /*
  186.          Display the location of NET.CFG
  187.       */
  188.       if  ( NULL == GetNetCfgPath() )
  189.          printf( "NET.CFG cannot be located\n" );
  190.       else
  191.          printf( "NET.CFG:  %s\n", GetNetCfgPath() );
  192.  
  193.       /*
  194.          Try each possible board # looking for loaded MLID's.
  195.       */
  196.       for ( board = 0; board <= maxLSLboards; board++ ) {
  197.          returnCode = GetMLIDConfig( board, &mlidConfig );
  198.          if  ( GMC_NO_MORE_ITEMS == returnCode )
  199.             break;   /* if no more board, break out of the loop */
  200.          else if  ( GMC_SUCCESS == returnCode ) {
  201.             /*
  202.                Note that the same MLID will often show up multiple
  203.                times here---once for each "frame type" you are using.
  204.                This is the "logical" board concept that ODI uses to
  205.                differentiate between frame types on a single card.
  206.  
  207.                If you need to filter out multiple logical cards that
  208.                represent the same MLID, you will have to use ad-hoc
  209.                means, such as comparing the MLID name plus the NIC
  210.                address in the table, or perhaps comparing the segment
  211.                values of the returned table pointers.
  212.             */
  213.             printf( "MLID:     " );
  214.             /*
  215.                Display MLID name and version number
  216.             */
  217.             CopyFarStringToLocal( buff, sizeof( buff ),
  218.                mlidConfig->CardShortName );
  219.             printf( "%-8s v%d.%02d", buff,
  220.                mlidConfig->MLIDMajorVer, mlidConfig->MLIDMinorVer );
  221.             /*
  222.                Display the frame type for this logical board
  223.             */
  224.             CopyFarStringToLocal( buff, sizeof( buff ),
  225.                mlidConfig->FrameString );
  226.             printf( "  (%s)\n", buff );
  227.          }  /* if we found the MLID */
  228.       }  /* for each possible MLID */
  229.  
  230.       /*
  231.          Try each possible protocol # looking for loaded protocols.
  232.       */
  233.       for ( protocol = 0; protocol <= maxLSLboards; protocol++ ) {
  234.          returnCode = GetProtocolConfig( protocol, &protocolConfig );
  235.          if  ( GMC_NO_MORE_ITEMS == returnCode )
  236.             break;   /* if no more protocols, break out of the loop */
  237.          else if  ( GMC_SUCCESS == returnCode ) {
  238.             printf( "Protocol: " );
  239.             CopyFarStringToLocal( buff, sizeof( buff ),
  240.                protocolConfig->ProtocolShortName );
  241.             printf( "%-8s v%d.%02d\n", buff,
  242.                protocolConfig->ProtocolMajorVer,
  243.                protocolConfig->ProtocolMinorVer );
  244.          }  /* if we found the protocol */
  245.       }  /* for each possible protocol */
  246.  
  247.    }  /* if LSL was present */
  248.  
  249.  
  250.    /*
  251.       Use VERIPX to get IPX and SPX versions.
  252.    */
  253.    printf( "\n" );
  254.    IPXver = GetIPXVersion();
  255.    if  ( 0 == IPXver )
  256.       printf( "IPX/SPX is not loaded\n" );
  257.    else {
  258.       printf( "IPX:      "
  259.          "v%d.%02d\n", HIBYTE( IPXver ), LOBYTE( IPXver ) );
  260.  
  261.       /* SPX can only be present if IPX is */
  262.       SPXver = GetSPXVersion();
  263.       if  ( 0 == SPXver )
  264.          printf( "SPX is not loaded\n" );
  265.       else
  266.          printf( "SPX:      "
  267.             "v%d.%02d\n", HIBYTE( SPXver ), LOBYTE( SPXver ) );
  268.    }
  269.  
  270.    /*
  271.       Use VERVLM to see if VLM is present.
  272.    */
  273.    printf( "\n" );
  274.    VLMver = GetVLMVersion( VLM_EXE );
  275.    if  ( 0 == VLMver )
  276.       printf( "VLM is not loaded\n" );
  277.    else {
  278.       printf( "VLM:      "
  279.          "v%d.%02d\n", HIBYTE( VLMver ), LOBYTE( VLMver ) );
  280.  
  281.       /*
  282.          Show the equivalent NETX version using the old calls.
  283.       */
  284.       NETXver = GetNetWareShellVersion( &NETXrev, &NETXtype );
  285.       if  ( 0 == NETXver )
  286.          printf( "   (NETX compatibility not loaded)\n" );
  287.       else
  288.          printf( "   (NETX compatibility is v%d.%02d)\n",
  289.             HIBYTE( NETXver ), LOBYTE( NETXver ) );
  290.  
  291.       /*
  292.          Show what other VLM modules are present.  We do this just by
  293.          iterating through many possible VLM ID #'s and checking to
  294.          see if each is loaded by calling its version number routine.
  295.       */
  296.       printf( "   VLM Modules loaded:" );
  297.       for ( vlmID = 2; vlmID <= VLM_NMR; vlmID++ ) {
  298.          VLMModuleVer = GetVLMVersion( vlmID );
  299.          if  ( VLMModuleVer ) {
  300.             if  ( 0 == ( vlmCount % 4 ) )
  301.                printf( "\n" );
  302.             vlmCount++;
  303.             printf( "    " );
  304.             switch ( vlmID ) {
  305.                /* show hex value for VLM's we don't recognize */
  306.                default : printf( "VLM#%04X", vlmID );          break;
  307.                /* otherwise show the name if known */
  308.                case VLM_AUTO     : printf( "AUTO    " );       break;
  309.                case VLM_BIND     : printf( "BIND    " );       break;
  310.                case VLM_CONN     : printf( "CONN    " );       break;
  311.                case VLM_FIO      : printf( "FIO     " );       break;
  312.                case VLM_GENERAL  : printf( "GENERAL " );       break;
  313.                case VLM_IPXNCP   : printf( "IPXNCP  " );       break;
  314.                case VLM_NDS      : printf( "NDS     " );       break;
  315.                case VLM_NETX     : printf( "NETX    " );       break;
  316.                case VLM_NMR      : printf( "NMR     " );       break;
  317.                case VLM_NWP      : printf( "NWP     " );       break;
  318.                case VLM_PNW      : printf( "PNW     " );       break;
  319.                case VLM_PRINT    : printf( "PRINT   " );       break;
  320.                case VLM_REDIR    : printf( "REDIR   " );       break;
  321.                case VLM_RSA      : printf( "RSA     " );       break;
  322.                case VLM_SECURITY : printf( "SECURITY" );       break;
  323.                case VLM_TRAN     : printf( "TRAN    " );       break;
  324.             }  /* switch vlmID */
  325.  
  326.             /*
  327.                If this VLM has a different version than VLM.EXE,
  328.                display it.  Currently this usually only happens with
  329.                NETX.VLM, but in the future, who knows?
  330.             */
  331.             if  ( VLMModuleVer != VLMver )
  332.                printf( " v%d.%02d",
  333.                   HIBYTE( VLMModuleVer ), LOBYTE( VLMModuleVer ) );
  334.             else
  335.                printf( "      " );
  336.          }  /* if VLM found */
  337.       }  /* for each possible VLM */
  338.       printf( "\n" );
  339.    }  /* VLM is present */
  340.  
  341.  
  342.    /*
  343.       Use VERNETX to get the NETX version.
  344.       (But only if VLM shell was not present!)
  345.    */
  346.    if  ( 0 == VLMver ) {
  347.       NETXver = GetNetWareShellVersion( &NETXrev, &NETXtype );
  348.       if  ( 0 == NETXver )
  349.          printf( "NETX is not loaded\n" );
  350.       else {
  351.          switch ( NETXtype ) {
  352.             default :
  353.             case  0 : printf( "NETX:   " );  break;
  354.             case  1 : printf( "EMSNETX:" );  break;
  355.             case  2 : printf( "XMSNETX:" );  break;
  356.          }
  357.          printf( "  v%d.%02d", HIBYTE( NETXver ), LOBYTE( NETXver ) );
  358.          printf ( " Rev. %c\n", (char)('A' + (char)NETXrev ) );
  359.       }  /* NETX is present */
  360.    }  /* VLM is not present */
  361.  
  362.    /*
  363.       Use VERLITE to get NetWare Lite version numbers.
  364.  
  365.       NOTE:  The low part of Lite version numbers is just one digit
  366.              unlike the other Novell version numbers.
  367.    */
  368.    printf( "\n" );
  369.    NWLClient = GetLiteClientVersion();
  370.    NWLServer = GetLiteServerVersion();
  371.    if  ( ( 0 == NWLClient ) && ( 0 == NWLServer ) )
  372.       /* Neither client nor server is loaded */
  373.       printf( "NetWare Lite is not loaded\n" );
  374.    else {
  375.       /*
  376.          Show if CLIENT.EXE is loaded
  377.       */
  378.       if  ( NWLClient )
  379.          printf( "NetWare Lite Client:  v%d.%1d\n",
  380.             HIBYTE( NWLClient ), LOBYTE( NWLClient ) );
  381.       else
  382.          printf( "NetWare Lite Client not loaded\n" );
  383.  
  384.       /*
  385.          Show if SERVER.EXE is loaded
  386.       */
  387.       if  ( NWLServer )
  388.          printf( "NetWare Lite Server:  v%d.%1d\n",
  389.             HIBYTE( NWLServer ), LOBYTE( NWLServer ) );
  390.       else
  391.          printf( "NetWare Lite Server not loaded\n" );
  392.    }
  393.  
  394.    return ( 0 );
  395. }  /* main() */
  396.  
  397. /*
  398.    CopyFarStringToLocal
  399.  
  400.    Copies a pascal-style string (length byte preceding)
  401.    that is pointed to by a far pointer, to a local buffer
  402.    so we can work with it more normally.
  403. */
  404. void CopyFarStringToLocal( char * local, size_t localSize,
  405.    char far * remote )
  406. {
  407.    int i;
  408.    int maxSize = (int)remote[ 0 ];
  409.  
  410.    if  ( maxSize > (int)localSize - 1 )
  411.       maxSize = (int)localSize - 1;
  412.  
  413.    for ( i = 0; i < maxSize; i++ )
  414.       if ( 0 == ( local[ i ] = remote[ i + 1 ] ) )
  415.          break;
  416.  
  417.    local[ i ] = 0;
  418. }  /* CopyFarStringToLocal() */
  419.  
  420.  
  421. /* eof: SHOWVER.C */